import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Bomb here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Bomb extends Attachable
{
    /**
     * Act - do whatever the Bomb wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    boolean init = false;
    boolean kill = false;
    public Bomb(){
      super(3,new GreenfootImage("bomb.png"));
      addAttatchmentPoint(new Location(0,0,0));
    }
    public void act() 
    {
        if(!init){
            setCoords(getX()-Play.getTrueX(), getY()-Play.getTrueY());
            init = true;
        }
        super.act();
        if(isTouching(Attachable.class) && !isTouching(TractorBeam.class) && (!( (getX() > 998)  || (getX() < 3) || (getY() > 597) || (getY() < 3) ) || !invisible)){
        setKill();
        
        }
        if(kill){
         getWorld().addObject(new Explosion(), getX(), getY());
         getWorld().removeObject(this);
        }
    }
    public void setKill(){
    kill = true;
    Play.beam.dettach();
    }
}
